<group>
<ul class='breadcrumb'><li><a href='%pathto:mdoc;'>Index</a></li><li><a href='%pathto:kmeans.vl_kmeans;'>Prev</a></li><li><a href='%pathto:misc.vl_alphanum;'>Next</a></li></ul><div class="documentation"><p>
D = <a href="%pathto:misc.vl_alldist2;">VL_ALLDIST2</a>(X,Y) returns the pairwise distance matrix D of the
columns of S1 and S2, yielding
</p><pre>
  D(i,j) = sum (X(:,i) - Y(:,j)).^2
</pre><p>
<a href="%pathto:misc.vl_alldist2;">VL_ALLDIST2</a>(X) returns the pairwise distance matrix fo the columns of
S, yielding
</p><pre>
  D(i,j) = sum (X(:,i) - X(:,j)).^2
</pre><p>
<a href="%pathto:misc.vl_alldist2;">VL_ALLDIST2</a>(...,'METRIC') changes the computed distance. Supported
values for METRIC are
</p><pre>
 METRIC  D(i,j)
 --------------------------------------------------------
  LINF   max |X  - Y|
  L2     sum (X  - Y).^2
  L1     sum |X  - Y|
  L0     sum (X ~= Y)
  CHI2   sum (X  - Y).^2 ./ (X + Y)
  HELL   sum (X^.5 - Y^.5) .^ 2
</pre><p>
(Notice that the standard definition of chi2 is half of what is
computed here).
</p><p>
<a href="%pathto:misc.vl_alldist2;">VL_ALLDIST2</a>(...,'KERNEL') computes the following 'kernels' K:
</p><pre>
 KERNEL  K(i,j)
 ---------------------------------------------------------
  KL2    sum X .* Y
  KL1    sum min (X, Y)
  KCHI2  2 * sum (X .* Y) ./ (X + Y)
  KHELL  (X .* Y) .^ 0.5
</pre><p>
The constant are chosen so that D(i,j) = K(i,i) + K(j,j) - 2 K(i,j)
where D is the metric corresponding to the kenrel (if the arguments
are non-negative vectors). Each kernel can be interpreted as the
inner product inducing the corresponding metric in an embedding of
the real space into an approrpiate reproducing Kenrel Hilbert
space.
</p><p>
<a href="%pathto:misc.vl_alldist2;">VL_ALLDIST2</a>() supports several storage classes. X and Y must have the
same storage class. The sotrage class of D is promoted to reduce
the chance of overvlow, but this is not checked.
</p><pre>
  X &amp; Y class      D class
 ---------------------------
  UINT8            UINT32
   INT8             INT32
  UINT16           UINT32
   INT16            INT32
  UINT32           UINT32
   INT32            INT32
  SINGLE           SINGLE
  DOUBLE           DOUBLE
</pre><p>
Warning: Both chi2 and kchi2 use integer math when presented with
integer data types. This can easily result in zeros where you did
not expect them.
</p><p>
See also: <a href="%pathto:vl_help;">VL_HELP</a>().
</p></div></group>
